<?php
/*if ($this->session->flashdata('message')){
	echo "<div class='message'>".$this->session->flashdata('message')."</div>";
}
else {
	echo "<p>Welcome to your page.</p>";
}*/
if ($this->session->flashdata('message')){
	echo "<div class='message'>".$this->session->flashdata('message')."</div>";
}
?>
<h1><?php echo $title;?></h1><br>
<?php
	// Resourece
	$resources = $this->MResource->getAllResources();
	if ( count($resources) )
	{
		echo '<h2> Resources </h2><br>';
		echo '<table cellpadding="0" cellspacing="0" border="0" class="bordered-table zebra-striped" id="example">';
		echo "<thead>\n<tr valign='top'>\n";
		echo "<th>No</th>\n<th>Resource type</th><th style='width:200px;'>Image</th><th>Semester</th><th>Shift</th><th>Group</th><th>Year</th><th>Course</th><th>Actions</th>\n";
		echo "</tr>\n</thead>\n<tbody>\n";
		$i = 1;
		foreach ($resources as $key => $list){
			echo "<tr valign='top'>\n";
			echo "<td align='center'>".$i++."</td>\n";
			echo "<td align='center'>".$list['file_type']."</td>\n";
			echo "<td align='center'>";
			$extension = pathinfo($list['file_src'], PATHINFO_EXTENSION);
			if (strtolower($extension)=='gif' || strtolower($extension)=='jpg' || strtolower($extension)=='png') {
				echo "<img title='view image' class='img-popup' style='style:width:50px; height:50px;'  src=".base_url().'images/'.$_SESSION['username'].'/'.$list['file_src']." />";			
			}
			elseif (strtolower($extension)=='flv' || strtolower($extension)=='mp4' || strtolower($extension)=='dat' || strtolower($extension)=='avi' ){
				echo "<a href=".base_url().'images/'.$_SESSION['username'].'/'.$list['file_src'].">".$list['file_src']."</a>";
			}
			else{
				echo "<a href=".base_url().'images/'.$_SESSION['username'].'/'.$list['file_src'] .">".$list['file_src']."</a>";
			} 
			echo "</td>\n";
			echo "<td align='center'>".$list['semester']."</td>\n";
			echo "<td align='center'>".$list['shift']."</td>\n";
			echo "<td align='center'>".$list['group']."</td>\n";
			//echo "<td align='center'>".$list['batch']."</td>\n";
			echo "<td align='center'>".$list['year']."</td>\n";
			echo "<td align='center'>".$list['course']."</td>\n";
			if($list['activate']==1) 
				$activate = 'active';
			else 
				$activate = 'inactive';
				
			//echo "<td align='center'>". $activate."</td>\n";
			echo "<td align='center'>";
			echo anchor('cresource/edit/'.$list['file_id'],'edit');
			echo " | ";
			echo anchor('cresource/delete/'.$list['file_id'],'delete',array('class'=>'delete-item'));
			echo "</td>\n";
			echo "</tr>\n";
		}
		echo "</tbody>\n</table>";
	}
	echo "<br />";
	// Course
	$courses = $this->MCourse->getCourses();
	if ( count($courses) )
	{
		echo '<h2> Course </h2><br>';
		echo '<table cellpadding="0" cellspacing="0" border="0" class="bordered-table zebra-striped" id="example">';
		echo "<thead>\n<tr valign='top'>\n";
		echo "<th>No</th>\n<th>Title</th><th>Short description</th><th>Actions</th>\n";
		echo "</tr>\n</thead>\n<tbody>\n";
		$i = 1;
		foreach ($courses as $key => $list){
			echo "<tr valign='top'>\n";
			echo "<td align='center'>".$i++."</td>\n";
			echo "<td align='center'>".$list['title']."</td>\n";
			echo "<td align='center'>".$list['shortdesc']."</td>\n";
			echo "<td align='center'>";
			echo anchor('ccourse/edit/'.$list['course_id'],'edit');
			echo " | ";
			echo anchor('ccourse/delete/'.$list['course_id'],'delete',array('class'=>'delete-item'));
			echo "</td>\n";
			echo "</tr>\n";
		}
		echo "</tbody>\n</table>";
	}
	echo "<br />";
	// Schedule
	$schedules = $this->MSchedule->getAllSchedules();
	if ( count($schedules) )
	{
		echo '<h2> Schedules </h2><br>';
		echo "<table id='rounded-corner' class='bordered-table zebra-striped' cellspacing='0' cellpadding='3' width='100%'>\n";
	echo "<thead>\n<tr valign='top'>\n";
	echo "<th>No</th><th>Source</th><th>Description</th><th>Semester</th><th>Academy</th><th>Actions</th>\n";
	echo "</tr>\n</thead>\n<tbody>\n";
	$i = 1;
	foreach ($schedules as $key => $list){
		echo "<tr valign='top'>\n";
		echo "<td align='center'>".$i++."</td>\n";
		echo "<td align='center'>";
		$extension = pathinfo($list['schedule_src'], PATHINFO_EXTENSION);
		if (strtolower($extension)=='gif' || strtolower($extension)=='jpg' || strtolower($extension)=='png') {
			echo "<img title='view image' class='img-popup' style='style:width:50px; height:50px;'  src=".base_url().'images/'.$_SESSION['username'].'/'.$list['schedule_src']." />";			
		}
		elseif (strtolower($extension)=='flv' || strtolower($extension)=='mp4' || strtolower($extension)=='dat' || strtolower($extension)=='avi' ){
			echo "<a href=".base_url().'images/'.$_SESSION['username'].'/'.$list['schedule_src'].">".$list['schedule_src']."</a>";
		}
		else{
			echo "<a href=".base_url().'images/'.$_SESSION['username'].'/'.$list['schedule_src'] .">".$list['schedule_src']."</a>";
		} 
		echo "</td>\n";
		echo "<td align='center'>".$list['description']."</td>\n";
		echo "<td align='center'>".$list['semester']."</td>\n";
		echo "<td align='center'>".$list['academy']."</td>\n";
		echo "<td align='center'>";
		echo anchor('cschedule/edit/'.$list['schedule_id'],'edit');
		echo " | ";
		echo anchor('cschedule/delete/'.$list['schedule_id'],'delete',array('class'=>'delete-item'));
		echo "</td>\n";
		echo "</tr>\n";
	}
	echo "</tbody>\n</table>";
	}
?>